//
// CleanerScoreScene class
//
var PausePanel = function () {
    cc.log("PausePanel");

    this.menu = this.menu || {};
    this.tip = this.tip || {};


};

PausePanel.TYPE_QUIT = 0;
PausePanel.TYPE_PAUSE = 1;
PausePanel.TYPE_BACK = 2;

PausePanel.prototype.onDidLoadFromCCB = function () {
//    this.rootNode.onUpdate = function (dt)
//    {
//        this.controller.onUpdate();
//    };
//    this.rootNode.schedule(this.rootNode.onUpdate);

    if (sys.platform == 'browser') {
        this.onEnter();
    }
    else {
        this.rootNode.onEnter = function () {
            this.controller.onEnter();
        };
    }

    this.rootNode.onExit = function () {
        this.controller.onExit();
    };

    this.rootNode.onTouchBegan = function () {
        cc.log("touches confirm layer! block touchEvent bubble!");
        return true;
    };

    this.rootNode._type = PausePanel.TYPE_PAUSE;
    this.rootNode.type = function (mType) {
        if (arguments.length == 0) {
            return this._type;
        } else {
            this._type = mType;
            switch (mType) {
                case PausePanel.TYPE_PAUSE:
                    this.controller.tip.setString("游戏暂停中。。。。");
                    break;
                case PausePanel.TYPE_BACK:
                    this.controller.tip.setString("确定要放弃吗？");
                    break;
                case PausePanel.TYPE_QUIT:
                    this.controller.tip.setString("确定要退出吗？");
                    break;
            }
        }
    }
};


PausePanel.prototype.onEnter = function () {
    this.menu.setTouchPriority(cc.MENU_HANDLER_PRIORITY - 2);
    cc.registerTargetedDelegate(cc.MENU_HANDLER_PRIORITY - 1, true, this.rootNode);
}

PausePanel.prototype.onUpdate = function () {

}

PausePanel.prototype.onExit = function () {
    cc.unregisterTouchDelegate(this.rootNode);
}

PausePanel.prototype.okClick = function () {
    switch (this.rootNode._type) {
        case PausePanel.TYPE_PAUSE:
            this.rootNode.removeFromParent();
            break;
        case PausePanel.TYPE_BACK:
            cc.BuilderReader.runScene("", "StartLayer");
            break;
        case PausePanel.TYPE_QUIT:
            cc.Director.end();
            break;
    }
}
PausePanel.prototype.noClick = function () {
    trace("noClick");
    this.rootNode.removeFromParent();
}
